﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Taste
{
    /// <summary>
    /// Extensions for the IStateMachine interface.
    /// </summary>
    public static class StateMachineExtensions
    {
        /// <summary>
        /// Defines a state.
        /// </summary>
        /// <param name="stateMachine">The state machine.</param>
        /// <param name="name">The name of the state.</param>
        /// <param name="onEntering">The action to perform when the state has been entered.</param>
        /// <param name="onLeaving">The action to perform when leaving the state.</param>
        public static void DefineState<TState, TTrigger>(this IStateMachine<TState, TTrigger> stateMachine, TState name, Action<ICurrentState<TState, TTrigger>> onEntering, Action<IStateTransition> onLeaving)
            where TState : struct
            where TTrigger : struct
        {
            stateMachine.DefineState(name, onEntering, (Action<IStateTransition<TState>>)(tr => onLeaving(tr)));
        }
    }
}
